import LineGraph from '../graph/linegraph.js'
import CircleGraph from '../graph/circlegraph.js'
import RectGraph from '../graph/rectgraph.js'
import DeviceGraph from './devicegraph.js'
import PolygonGraph from '../graph/polygon.js'
import TerminalGraph from '../graph/terminal.js'
import multiselrectgraph from './multiselrectgraph.js'
import textgraph from './textgraph.js'
import imgegraph from './imagegraph.js'
import commlinegraph from './commlinegraph.js'
import beziercurve from './beziercurve.js'
import quadraticCurve from './quadraticCurve.js'
import combinegraph from './combinegraph.js'
import arcgraph from './arcgraph.js'
import auxlinegraph from './auxlinegraph.js'
import containerGraph from './containerGraph.js'
import multistargraph from './extendGraph/multistargraph.js'
import regularpolygon from './extendGraph/regularpolygon.js'
import cylindergraph from './extendGraph/cylindergraph.js'
import cubegraph from './extendGraph/cubegraph.js'
import specialrectangle from './extendGraph/specialrectangle.js'
import spllinegraph from './spllinegraph.js'
import ellipsegraph from './ellipsegraph.js'
import ellipsearcgraph from './ellipsearcgraph.js'
import pathgraph from './pathgraph.js'

import {CGraphTypeUtil} from './paintutil/graphtypeutil.js'

import {LGXEnums}  from '../common/sysenum.js'

var GraphFactory = {

}


GraphFactory.createGraphByType32 = function (fulltoolKind, symbol) {
    var type = CGraphTypeUtil.getType32(fulltoolKind, symbol);
    var pNewGraph = this.createGraphByEnums(fulltoolKind, type);
    return pNewGraph;
}

GraphFactory.createGraphByEnums = function (fulltoolKind, enusType) {
    var pNewGraph = null;
    switch (enusType) {
        case LGXEnums.LGXGraphType.LineGraph_type:
            pNewGraph = new LineGraph.LineGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.CircleGraph_type:
            pNewGraph = new CircleGraph.CircleGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.PolygonGraph_type:
            pNewGraph = new PolygonGraph.PolygonGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.ImageGraph_type:
            pNewGraph = new imgegraph.ImageGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.RectGraph_type:
            pNewGraph = new RectGraph.RectGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.MoldGraph_type:
            pNewGraph = new DeviceGraph.DeviceGraph(fulltoolKind);
            break;


        case LGXEnums.LGXGraphType.CommBusGraph_type:
            pNewGraph = new commlinegraph.CommLineGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.TextGraph_type:
            pNewGraph = new textgraph.TextGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.TerminalGraph_type:
            pNewGraph = new TerminalGraph.TerminalGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.PipeLineGraph_Type:
            pNewGraph = new CPipeLineGraph();
            break;

        case LGXEnums.LGXGraphType.TimerCtrl_type:
            pNewGraph = new CTimerCtrlGraph();
            break;

        case LGXEnums.LGXGraphType.MultiSel_Rect_Type:
            pNewGraph = new multiselrectgraph.MultiSelRectGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.QuadraticCurve_type:
            pNewGraph = new quadraticCurve.QuadraticCurveGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.BezierCurve_type:
            pNewGraph = new beziercurve.BezierCurveGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Path_type:
            pNewGraph = new pathgraph.PathGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.ArcGraph_type:
            // console.log("arc********************");
            pNewGraph = new arcgraph.ArcGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.dimLine_type:
            pNewGraph = new linedimensiongraph.LineDimensionGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.dimAlign_type:
            pNewGraph = new aligndimensiongraph.AlignDimensionGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.dimRadius_type:
            pNewGraph = new radiusdimensiongraph.RadiusDimensionGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.dimAngle_type:
            pNewGraph = new angledimensiongraph.AngleDimensionGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.dimArc_type:
            pNewGraph = new arcdimensiongraph.ArcDimensionGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Auxline_type:
            pNewGraph = new auxlinegraph.AuxLineGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.umlpackage_type:
            pNewGraph = new umlpackagegraph.UMLPackageGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.containerItem_type:
            pNewGraph = new ItemMoldGraph.ItemMoldGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Container_type:
            pNewGraph = new containerGraph.ContainerMoldGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Combine_type:
            pNewGraph = new combinegraph.CombineGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Cylinder_type:
            pNewGraph = new cylindergraph.CylinderGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Cube_type:
            pNewGraph = new cubegraph.CubeGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.SpecialRect_type:
            pNewGraph = new specialrectangle.SpecialRectangleGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.RegularPolygon_type:
            pNewGraph = new regularpolygon.RegularPolygonGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.MultiStar_type:
            pNewGraph = new multistargraph.MultiStarGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.XMindTheme_type:
            pNewGraph = new xmindthemegraph.XMindThemeGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.DimTextGraph_type:
            pNewGraph = new dimtextgraph.DimTextGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.dimDiameter_type:
            pNewGraph = new diameterdimgraph.DiameterDimGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.SplineGraph_type:
            pNewGraph = new spllinegraph.SPolyLineGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.EllipseGraph_type:
            pNewGraph = new ellipsegraph.EllipseGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.EllipseArcGraph_type:
            pNewGraph = new ellipsearcgraph.EllipseArcGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.Hatch_type:
            pNewGraph = new hatchgraph.HatchGraph(fulltoolKind);
            break;

        case LGXEnums.LGXGraphType.CADText_type:
            pNewGraph = new CADTextGraph.CADTextGraph(fulltoolKind);
            break;

        default:
            break;
    }

    return pNewGraph;
}

GraphFactory.createSpecialPolygonByFullKind = function (fulltoolKind) {
    var pNewGraph = null;
    let subKind = fulltoolKind & 0x0000ff00;
    subKind = subKind >> 8;
    if (subKind == 0x01) {
        pNewGraph = new regularpolygon.RegularPolygonGraph(fulltoolKind);
    }
    else if (subKind == 0x02) {
        pNewGraph = new multistargraph.MultiStarGraph(fulltoolKind);
    }
    else {
        pNewGraph = new PolygonGraph.PolygonGraph(fulltoolKind);
    }
    return pNewGraph;
}


export default { GraphFactory }

